package com.captain.special.二叉树.简单;

import com.captain.leetcode.TreeNode;

/**
 * Des:
 *
 * @author XL
 * @Date 2022/5/6 16:14
 */
public class 对称二叉树101 {
    public boolean isSymmetric(TreeNode root) {
        return recur(root.left, root.right);
    }

    public boolean recur(TreeNode left, TreeNode right) {
        if (left == null && right == null) {
            return true;
        }
        if (left == null || right == null) {
            return false;
        }
        if (left.val != right.val) {
            return false;
        }
        boolean leftRes = recur(left.left, right.right);
        boolean rightRes = recur(left.right, right.left);
        return leftRes && rightRes;
    }
}
